import request from '@/utils/request'

/**
 * 根据订单编号，获取订单详细信息
 * @param {String} orderSn
 */
export function fetchByOrderSn(orderSn) {
  return request({
    url: '/index/order/detail',
    method: 'GET',
    params: { order_sn: orderSn }
  })
}
/**
 * 获取当前用户的订单数据列表
 * @param {Object} query
 */
export function fetchUserList(query) {
  return request({
    url: '/index/order/index',
    method: 'GET',
    params: query
  })
}
/**
 * 用户删除自己的订单数据
 * @param {String} id
 */
export function deleteUserOne(id) {
  return request({
    url: '/index/order/delete',
    method: 'DELETE',
    params: {
      id: id
    }
  })
}
export function fetchList(query) {
  return request({
    url: '/admin/order/index',
    method: 'GET',
    params: query
  })
}
export function fetchOne(id) {
  return request({
    url: '/admin/order/detail',
    method: 'GET',
    params: { id }
  })
}
export function updateOne(data) {
  return request({
    url: '/admin/order/update',
    method: 'post',
    data
  })
}

export function deleteOne(id) {
  return request({
    url: '/admin/order/delete',
    method: 'DELETE',
    params: {
      id: id
    }
  })
}
export function createOne(data) {
  return request({
    url: '/index/order/create',
    method: 'POST',
    data
  })
}
export function fecthOrderGoods(orderSn) {
  return request({
    url: '/admin/order/ordergoods',
    method: 'get',
    params: {
      order_sn: orderSn
    }
  })
}
